/*
* Copyright (c) 2011 Connection Road.  All rights reserved.
* This program and the accompanying material are made available
* under the terms of the Eclipse Public Licnese v1.0 which is
* available at http://www.eclipse.org/legal/epl-v10.html
*/

namespace CrSyncFilesUtils
{
    /// <summary>
    /// Convenience class for holding synchronization statistics
    /// </summary>
    
    public class CrSyncFileStatistics
    {
        
        public CrSyncFileStatistics()
        {
        }

        public CrSyncFileStatistics(string message)
        {
            Message = message;
        }

        public CrSyncFileStatistics(int progress)
        {
            Progress = progress;
        }

        public CrSyncFileStatistics(CrSyncFileCountHolder deletedFolder,
                                            CrSyncFileCountHolder deletedFiles,
                                            CrSyncFileCountHolder renamedFiles,
                                            CrSyncFileCountHolder createdFolders,
                                            CrSyncFileCountHolder createdFiles,
                                            CrSyncFileCountHolder overwrittenFiles,
                                            CrSyncFileCountHolder skippedFiles,
                                            long totalBytes)
        {
            TotalDeletedFiles = deletedFiles;
            TotalDeletedFolders = deletedFolder;
            TotalCreatedFiles = createdFiles;
            TotalCreatedFolders = createdFolders;
            TotalOverWrittenFiles = overwrittenFiles;
            TotalRenamedFiles = renamedFiles;
            TotalSkippedFiles = skippedFiles;
            TotalBytes = totalBytes;
            SetTotalOperations();
        }

        public CrSyncFileStatistics(CrSyncFileCountHolder deletedFolder,
                                            CrSyncFileCountHolder deletedFiles,
                                            CrSyncFileCountHolder renamedFiles,
                                            CrSyncFileCountHolder createdFolders,
                                            CrSyncFileCountHolder createdFiles,
                                            CrSyncFileCountHolder overwrittenFiles,
                                            CrSyncFileCountHolder skippedFiles,
                                            long totalBytes,
                                            int progress)
        {
            TotalDeletedFiles = deletedFiles;
            TotalDeletedFolders = deletedFolder;
            TotalCreatedFiles = createdFiles;
            TotalCreatedFolders = createdFolders;
            TotalOverWrittenFiles = overwrittenFiles;
            TotalRenamedFiles = renamedFiles;
            TotalSkippedFiles = skippedFiles;
            TotalBytes = totalBytes;
            Progress = progress;

            SetTotalOperations();
        }


        public CrSyncFileStatistics(int? progress, 
                                    CrSyncFileCountHolder totalDeletedFolders,
                                    CrSyncFileCountHolder totalDeletedFiles,
                                    CrSyncFileCountHolder totalRenamedFiles,
                                    CrSyncFileCountHolder totalCreatedFolders,
                                    CrSyncFileCountHolder totalCreatedFiles,
                                    CrSyncFileCountHolder totalOverWrittenFiles,
                                    CrSyncFileCountHolder totalSkippedFiles, 
                                    long? totalBytes, 
                                    string message)
        {
            Progress = progress;
            TotalDeletedFolders = totalDeletedFolders;
            TotalDeletedFiles = totalDeletedFiles;
            TotalRenamedFiles = totalRenamedFiles;
            TotalCreatedFolders = totalCreatedFolders;
            TotalCreatedFiles = totalCreatedFiles;
            TotalOverWrittenFiles = totalOverWrittenFiles;
            TotalSkippedFiles = totalSkippedFiles;
            TotalBytes = totalBytes;
            Message = message;

            SetTotalOperations();
        }

        public CrSyncFileStatistics(long? totalFilesFound, long? totalDirectoriesFound, long? totalFileSizeFound, string message)
        {
            TotalFilesFound = totalFilesFound;
            TotalDirectoriesFound = totalDirectoriesFound;
            TotalFileSizeFound = totalFileSizeFound;
            Message = message;
        }

        public CrSyncFileStatistics(long? totalFilesFound, long? totalDirectoriesFound, long? totalFileSizeFound)
        {
            TotalFilesFound = totalFilesFound;
            TotalDirectoriesFound = totalDirectoriesFound;
            TotalFileSizeFound = totalFileSizeFound;
        }

        public int? Progress { get; set; }
        public CrSyncFileCountHolder TotalDeletedFolders { get; set; }
        public CrSyncFileCountHolder TotalDeletedFiles { get; set; }
        public CrSyncFileCountHolder TotalRenamedFiles { get; set; }
        public CrSyncFileCountHolder TotalCreatedFolders { get; set; }
        public CrSyncFileCountHolder TotalCreatedFiles { get; set; }
        public CrSyncFileCountHolder TotalOverWrittenFiles { get; set; }
        public CrSyncFileCountHolder TotalSkippedFiles { get; set; }
        public CrSyncFileCountHolder TotalOperations { get; set; }
        public long? TotalBytes { get; set; }
        public string Message { get; set; }

        public long? TotalFilesFound { get; set; }
        public long? TotalDirectoriesFound { get; set; }
        public long? TotalFileSizeFound { get; set; }

        private void Init()
        {
            TotalDeletedFolders = new CrSyncFileCountHolder();
            TotalDeletedFiles = new CrSyncFileCountHolder();
            TotalRenamedFiles = new CrSyncFileCountHolder();
            TotalCreatedFiles = new CrSyncFileCountHolder();
            TotalCreatedFolders = new CrSyncFileCountHolder();
            TotalOverWrittenFiles = new CrSyncFileCountHolder();
            TotalSkippedFiles = new CrSyncFileCountHolder();
        }

        private void SetTotalOperations()
        {
            TotalOperations = new CrSyncFileCountHolder();
            TotalOperations.Add(TotalDeletedFolders);
            TotalOperations.Add(TotalDeletedFiles);
            TotalOperations.Add(TotalRenamedFiles);
            TotalOperations.Add(TotalCreatedFolders);
            TotalOperations.Add(TotalCreatedFiles);
            TotalOperations.Add(TotalOverWrittenFiles);
            TotalOperations.Add(TotalSkippedFiles);
        }
    }
}
